<template>
  <div class="content">
    <div class="header">实时出工人数</div>
    <div class="num">{{ detailData.actualAttendance }}</div>
    <div class="body">
      <div id="echarts" style="width:100%;height:36px" />
    </div>
    <div class="footer">
      <div class="left">
        <span>管理人员</span>
        <span class="num ml-10">{{ detailData.administrators }}</span>
      </div>
      <!-- <div class="right">
        <span>个人</span>
        <span class="num ml-10">111111人</span>
      </div> -->
    </div>
  </div>
</template>

<script>
import { summaryData } from '@/api/autonym'
export default {
  data() {
    return {
      detailData: {}
    }
  },
  mounted() {
    this.getDetail()
    this.echartInit()
  },
  methods: {
    async getDetail() {
      const res = await summaryData(this.listQuery)
      if (res.code === 200) {
        if (res.data) {
          this.detailData = res.data
        }
      }
    },
    echartInit() {
      const myChart = this.$echarts.init(document.getElementById('echarts'))
      const option = {
        grid: {
          left: 0,
          right: 0,
          bottom: 0,
          top: 0
        },
        xAxis: {
          type: 'category',
          axisTick: { show: false },
          boundaryGap: false,
          data: [
            2,
            1,
            3,
            2.5,
            5,
            2,
            4,
            5,
            5.6,
            1,
            1.2,
            1.4,
            4,
            5,
            6,
            3,
            2,
            1,
            0
          ]
        },
        yAxis: {
          type: 'value',
          show: false
        },
        series: [
          {
            data: [
              2,
              1,
              3,
              2.5,
              5,
              2,
              4,
              5,
              5.6,
              1,
              1.2,
              1.4,
              4,
              5,
              6,
              3,
              2,
              1,
              0
            ],
            type: 'line',
            smooth: true, // 是否平滑曲线显示
            symbolSize: 0,
            lineStyle: {
              normal: {
                color: 'rgba(0, 215, 227, 1)' // 线条颜色
              }
            },
            areaStyle: {
              // 区域填充样式
              normal: {
                // 线性渐变，前4个参数分别是x0,y0,x2,y2(范围0~1);相当于图形包围盒中的百分比。如果最后一个参数是‘true’，则该四个值是绝对像素位置。
                color: new this.$echarts.graphic.LinearGradient(
                  0,
                  0,
                  0,
                  1,
                  [
                    { offset: 0, color: 'rgba(0, 215, 227, 1)' },
                    { offset: 0.7, color: 'rgba(0, 215, 227, 1)' }
                  ],
                  false
                )
              }
            },
            label: {
              show: false
            }
          }
        ]
      }

      myChart.setOption(option, (window.onresize = myChart.resize))
    }
  }
}
</script>

<style scoped lang="scss">
.content {
  width: 100%;
  height: 172px;
  padding: 16px;
  border-radius: 2px;
  border: 1px solid rgba(221, 221, 221, 0.2);
  .header {
    margin-bottom: 10px;
    .more {
      float: right;
      color: rgba(247, 181, 0, 1);
    }
  }
  .body {
    padding-bottom: 20px;
    border-bottom: 1px solid rgba(221, 221, 221, 0.2);
  }
  .num {
    font-size: 16px;
    color: #ffffff;
  }
  .footer {
    display: flex;
    margin-top: 15px;
    .num {
      font-size: 14px;
    }
    .left {
      display: flex;
      align-items: center;
      justify-content: flex-start;
      flex: 1;
    }
    .right {
      display: flex;
      align-items: center;
      justify-content: flex-end;
      flex: 1;
    }
    .ml-10 {
      margin-left: 10px;
    }
  }
}
</style>
